﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Data;

/// <summary>
/// Summary description for bzUCBase
/// </summary>
public class bzUCBase:System.Web.UI.UserControl
{
    //----------------------------------------------------------
    private DataRow _SiteOption = null;
    public DataRow SiteOption { get { return _SiteOption; } }

    private DataRow _Lang = null;
    public DataRow Lang { get { return _Lang; } }

    private string _Act = "";
    public string Act { get { return _Act; } }

    private string _CurrentLang = "VN";
    public string CurrentLang { get { return _CurrentLang; } }    



    public void initSiteLang(string sSiteCate,string sSiteNote,string sLangNote)
    {
        this.checkDomainID();
        Session["Lang"] = bzLang.checkLang(Request.QueryString["Lang"] == null ? Session["Lang"].ToString() : Request.QueryString["Lang"]);
        _Act = string.IsNullOrEmpty(Request.QueryString["Act"]) ? "" : Request.QueryString["Act"];

        _CurrentLang = Session["Lang"].ToString().ToUpper().Trim();
        _SiteOption = new bzSiteOption(sSiteCate, sSiteNote).SiteOption;
        _Lang = new bzLang(Session["Lang"].ToString(), sLangNote).Lang;        
    }
    private void checkDomainID()
    {
        object[] obj ={ 
            Request.QueryString["Page"],
            Request.QueryString["Limit"],
            Request.QueryString["ID"],
            Request.QueryString["CateID"]
        };
        if (!bzStringClass.checkDomainID(obj))
        {
            Response.Redirect(bzStringClass.ErrorPage);
        }       
       
    }
    //----------------------------------------------------------------------------------



	public bzUCBase()
	{
		//
		// TODO: Add constructor logic here
		//
	}
    protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);
    }

    //----------------------------
    private string _Pagination = "";
    public string Pagination { get { return _Pagination; } }

    private string _PaginationHot = "";
    public string PaginationHot { get { return _PaginationHot; } }

    private string _PaginationNew = "";
    public string PaginationNew { get { return _PaginationNew; } }

    private string _PaginationHotBuy = "";
    public string PaginationHotBuy { get { return _PaginationHotBuy; } }

    private string _Page = "0";
    public string PageNum { get { return _Page; } }

    public void loadPaginationReplaceURL(long total,int limit,string sURL)
    {
        _Page = Request.QueryString["Page"] == null ? "1" : this.IsPostBack ? "1" : Request.QueryString["Page"];
        
        bzPagination pg = new bzPagination();
        pg.Limit = Convert.ToInt32(limit);
        pg.PageNumber = Convert.ToInt32(_Page);
        pg.Total = total;
        pg.Page = this.Lang["PageString"].ToString();
        pg.Next = this.Lang["PageNext"].ToString();
        pg.Last = this.Lang["PageLast"].ToString();
        pg.Previous = this.Lang["PagePrevious"].ToString();
        pg.First = this.Lang["PageFirst"].ToString();
        pg.ItemShowNumber = Convert.ToInt32(this.SiteOption["PageItemShow"]);
        pg.URL = sURL;
        _Pagination = pg.getStringPagination(".", ".html");
    }
    public void loadPaginationReplaceURLHot(long total, int limit, string sURL)
    {
        _Page = Request.QueryString["PageHot"] == null ? "1" : this.IsPostBack ? "1" : Request.QueryString["PageHot"];

        bzPagination pg = new bzPagination();
        pg.Limit = Convert.ToInt32(limit);
        pg.PageNumber = Convert.ToInt32(_Page);
        pg.Total = total;
        pg.Page = this.Lang["PageString"].ToString();
        pg.Next = this.Lang["PageNext"].ToString();
        pg.Last = this.Lang["PageLast"].ToString();
        pg.Previous = this.Lang["PagePrevious"].ToString();
        pg.First = this.Lang["PageFirst"].ToString();
        pg.ItemShowNumber = Convert.ToInt32(this.SiteOption["PageItemShow"]);
        pg.URL = sURL;
        _PaginationHot = pg.getStringPagination(".", ".html");
    }
    public void loadPaginationReplaceURLNew(long total, int limit, string sURL)
    {
        _Page = Request.QueryString["PageNew"] == null ? "1" : this.IsPostBack ? "1" : Request.QueryString["PageNew"];

        bzPagination pg = new bzPagination();
        pg.Limit = Convert.ToInt32(limit);
        pg.PageNumber = Convert.ToInt32(_Page);
        pg.Total = total;
        pg.Page = this.Lang["PageString"].ToString();
        pg.Next = this.Lang["PageNext"].ToString();
        pg.Last = this.Lang["PageLast"].ToString();
        pg.Previous = this.Lang["PagePrevious"].ToString();
        pg.First = this.Lang["PageFirst"].ToString();
        pg.ItemShowNumber = Convert.ToInt32(this.SiteOption["PageItemShow"]);
        pg.URL = sURL;
        _PaginationNew = pg.getStringPagination(".", ".html");
    }
    public void loadPaginationReplaceURLHotBuy(long total, int limit, string sURL)
    {
        _Page = Request.QueryString["PageHotBuy"] == null ? "1" : this.IsPostBack ? "1" : Request.QueryString["PageHotBuy"];

        bzPagination pg = new bzPagination();
        pg.Limit = Convert.ToInt32(limit);
        pg.PageNumber = Convert.ToInt32(_Page);
        pg.Total = total;
        pg.Page = this.Lang["PageString"].ToString();
        pg.Next = this.Lang["PageNext"].ToString();
        pg.Last = this.Lang["PageLast"].ToString();
        pg.Previous = this.Lang["PagePrevious"].ToString();
        pg.First = this.Lang["PageFirst"].ToString();
        pg.ItemShowNumber = Convert.ToInt32(this.SiteOption["PageItemShow"]);
        pg.URL = sURL;
        _PaginationHotBuy = pg.getStringPagination(".", ".html");
    }
    public void loadPaginationReplaceURLPage(long total, int limit, string sURL)
    {
        _Page = Request.QueryString["Page"] == null ? "1" : this.IsPostBack ? "1" : Request.QueryString["Page"];

        bzPagination pg = new bzPagination();
        pg.Limit = Convert.ToInt32(limit);
        pg.PageNumber = Convert.ToInt32(_Page);
        pg.Total = total;
        pg.Page = this.Lang["PageString"].ToString();
        pg.Next = this.Lang["PageNext"].ToString();
        pg.Last = this.Lang["PageLast"].ToString();
        pg.Previous = this.Lang["PagePrevious"].ToString();
        pg.First = this.Lang["PageFirst"].ToString();
        pg.ItemShowNumber = Convert.ToInt32(this.SiteOption["PageItemShow"]);
        pg.URL = sURL;
        _Pagination = pg.getStringPagination(".html");
    }
    public void loadPagination(long total, int limit, string sURL)
    {
        _Page = Request.QueryString["Page"] == null ? "1" : this.IsPostBack ? "1" : Request.QueryString["Page"];

        bzPagination pg = new bzPagination();
        pg.Limit = Convert.ToInt32(limit);
        pg.PageNumber = Convert.ToInt32(_Page);
        pg.Total = total;
        pg.Page = this.Lang["PageString"].ToString();
        pg.Next = this.Lang["PageNext"].ToString();
        pg.Last = this.Lang["PageLast"].ToString();
        pg.Previous = this.Lang["PagePrevious"].ToString();
        pg.First = this.Lang["PageFirst"].ToString();
        pg.ItemShowNumber = Convert.ToInt32(this.SiteOption["PageItemShow"]);
        pg.URL = sURL;
        _Pagination = pg.getStringPagination();
    }
    public void loadPaginationAjax(long total, int limit, string sURL,int ajaxCase)
    {
        _Page = Request.QueryString["Page"] == null ? "1" : this.IsPostBack ? "1" : Request.QueryString["Page"];

        bzPagination pg = new bzPagination();
        pg.Limit = Convert.ToInt32(limit);
        pg.PageNumber = Convert.ToInt32(_Page);
        pg.Total = total;
        pg.Page = this.Lang["PageString"].ToString();
        pg.Next = this.Lang["PageNext"].ToString();
        pg.Last = this.Lang["PageLast"].ToString();
        pg.Previous = this.Lang["PagePrevious"].ToString();
        pg.First = this.Lang["PageFirst"].ToString();
        pg.ItemShowNumber = Convert.ToInt32(this.SiteOption["PageItemShow"]);
        pg.URL = sURL;
        _Pagination = pg.getStringPaginationAjax(ajaxCase);
    }
}
